<?php 
class Admin_LoginController extends Zend_Controller_Action{ 
	public function init(){
		$this->_sess = new Zend_Session_Namespace();
		$this->_helper->layout->setLayout('login');
	}
	public function indexAction(){
		if($this->_request->isPost()){
			$email = $this->_request->getPost('email');
			$password = $this->_request->getPost('password');
			$mode = new Admin_Model_Login;
			$data = $mode->check_login($email,$password);
			if(@$data){
				$this->_sess->id = $data[0]['user_id'];
				$this->_helper->redirector('index','index','admin');
			}
			else{
				$this->view->error = 'Login Error';
			}
		}
	}
	public function logoutAction(){
		unset($this->_sess->id);
		$this->_helper->redirector('index','login','admin');
	}
}
